#include <iostream>

using namespace std;

// FIXME: 第一次输入a是正确的，为何第二次输入b不对

int main()
{
    const char key[] = {'a', 'b', 'a', 'd', 'c'};                                  //定义正确答案存放于数组中
    const int NUM_QUES = 5;                                                  //定义输入的答案个数
    char c;
    int ques = 0, numcorrect = 0;                                            //定义输入答案的下标与正确答案数

    cout << "Please enter the " << NUM_QUES << " question tests : " << endl;

    while (cin.get(c))
    {
        if (c != '\n')
        {
            if (c == key[ques])                                              //当输入与答案相同时，输出“*”
            {
                numcorrect++;
                cout << "*";
            }
            else cout << "#";
            ques++;
        }
        else
        {
            cout << " Score : " << static_cast<float>(numcorrect) / NUM_QUES * 100 << "%";

            ques = 0;
            numcorrect = 0;

            cout << endl;
        }
    }
    
    return 0;
}
